FROM python:3.7-alpine

MAINTAINER Milton

# Install required packages and remove the apt packages cache when done.

RUN echo http://mirrors.aliyun.com/alpine/v3.12/main > /etc/apk/repositories \
    && echo http://mirrors.aliyun.com/alpine/v3.12/community >> /etc/apk/repositories \
    && apk update \
    && apk --update add --no-cache gcc \
    && apk --update add --no-cache g++ \
    && apk --update add --no-cache tzdata \
    && apk --update add --no-cache musl-dev \
    && apk --update add --no-cache linux-headers

ENV  TIME_ZONE Asia/Shanghai

RUN echo "${TIME_ZONE}" > /etc/timezone \
    && ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime

ENV PYTHONUNBUFFERED 1

WORKDIR /app

VOLUME ["/app"]

COPY . .

ENV PIPURL "https://pypi.tuna.tsinghua.edu.cn/simple"

RUN pip --no-cache-dir install  -i ${PIPURL} --upgrade pip \
    && pip  install  -i ${PIPURL} -r requirements.txt \
    && pip  install  -i ${PIPURL} gunicorn \
    && chmod +x start.sh

EXPOSE 8001

CMD ./start.sh